package com.qk.management.handle;

import com.qk.common.Result;
import com.qk.common.exception.CommonException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: zyx
 * @created: 2025-10-07-09:51
 * @description:
 */
@Slf4j
@RestControllerAdvice
public class MyGlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e){
        log.error("服务器发生异常:{}", e.getMessage());
        return Result.error("网络异常，请稍后重试");
    }
    @ExceptionHandler(CommonException.class)
    public Result handleCommonException(CommonException e){
        log.error("参数错误: {}", e.getMessage());
        return Result.error(e.getMessage());
    }
}
